﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- STYLESHEETS -->

    <link rel="stylesheet" type="text/css" href="../../css/cloud-admin.css">
    <link rel="stylesheet" type="text/css" href="../../css/themes/default.css" id="skin-switcher">
    <link rel="stylesheet" type="text/css" href="../../css/responsive.css">

    <link href="../../font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- file-input -->
    <link rel="stylesheet" type="text/css" href="../../js/file-input/fileinput.css"/>
    <!-- SELECT2 -->
    <link rel="stylesheet" type="text/css" href="../../js/select2/select2.min.css"/>
    <!-- UNIFORM -->
    <link rel="stylesheet" type="text/css" href="../../js/uniform/css/uniform.default.min.css"/>
    <!-- datatable -->
    <link rel="stylesheet" href="../../js/datatables/datatable.css">
    <!-- WIZARD -->
    <link rel="stylesheet" type="text/css" href="../../js/bootstrap-wizard/wizard.css"/>

    <!-- JQUERY -->
    <script src="../../js/jquery/jquery-2.0.3.min.js"></script>
    <script src="../../js/common.js"></script>
</head>

<body>
<header class="navbar clearfix" id="header"></header>

<!-- PAGE -->
<section id="page">
    <!-- SIDEBAR -->
    <div id="sidebar" class="sidebar">
        <div class="sidebar-menu nav-collapse">

            <!-- SIDEBAR MENU -->
            <ul>


            </ul>
            <!-- /SIDEBAR MENU -->
        </div>

    </div>
    <!-- /SIDEBAR -->
    <div id="main-content">
        <!-- 选择图片 -->
        <div class="modal fade" id="box-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <form id="form_Images">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">选择图片</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group mrg-bt10">
                                <label class="control-label col-sm-3" style="line-height: 34px;">图片类型：</label>
                                <div class="col-md-3">
                                    <select id="ImagesType_select" class="col-md-12 select2-offscreen" tabindex="-1">
                                        <option value="-1">选择类型</option>
                                        <option value="QuantityCheck">质检报告</option>
                                        <option value="Size">尺码</option>
                                    </select>
                                </div>

                                <div class="col-sm-1">
                                    <a class="btn btn-primary searchImages">查询</a>
                                </div>
                                <div style="line-height: 34px; color: red; margin-left: 20px" class="col-sm-4">图片可点击查看大图</div>
                            </div>
                            <div class="form-group mrg-bt10" style="height: auto;">
                                <table id="db_Images_list" cellpadding="0" cellspacing="0" border="0"
                                       class="datatable table table-striped table-bordered table-hover">

                                </table>
                            </div>

                        </div>

                    </div>
                </form>

            </div>
        </div>

        <!-- end -->
        <!-- 选择款式 -->
        <div class="modal fade" id="editGroup" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <form id="form_focus">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">选择款式</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row ">
                                <input type="text" class="form-control width-50" name="gName" placeholder="请输入关键字" maxlength="50"/>
                                <button type="button" class="btn btn-success" id="searchGroup">查询</button>
                                <span style="color:red">双击行选中</span>

                            </div>
                            <div class="row ">

                                <!--<select id="group_select" name="group" style="width: 50%">
                                </select>-->
                                <table class="table table-bordered">
                                    <thead style="font-weight:bold">
                                    <tr>
                                        <td>款式名称</td>
                                    </tr>
                                    </thead>
                                    <tbody id="tb_group"></tbody>

                                </table>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
        </div>
        <!-- end 选择款式 -->
        <!-- 选择商家 -->
        <div class="modal fade" id="editSupplier" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <form id="form_focus">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">选择商家</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row ">
                                <input type="text" class="form-control width-50" name="txt_supplierName" placeholder="请输入关键字" maxlength="50"/>
                                <button type="button" class="btn btn-success" id="searchSupplier">查询</button>
                                <span style="color:red">双击行选中</span>

                            </div>
                            <div class="row ">
                                <table class="table table-bordered">
                                    <thead style="font-weight:bold">
                                    <tr>
                                        <td>商家名称</td>
                                    </tr>
                                    </thead>
                                    <tbody id="tb_supplier"></tbody>

                                </table>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
        </div>
        <!-- end 选择商家 -->
        <!-- 选择品牌-->
        <div class="modal fade" id="editBrand" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <form id="form_focus">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">选择品牌</h4>
                        </div>
                        <div class="modal-body">
                            <div class="row ">
                                <span style="color:red">双击行选中</span>
                            </div>
                            <div class="row ">


                                <table class="table table-bordered">
                                    <thead style="font-weight:bold">
                                    <tr>
                                        <td>品牌名称</td>
                                    </tr>
                                    </thead>
                                    <tbody id="tb_brand"></tbody>

                                </table>
                            </div>
                        </div>

                    </div>
                </form>
            </div>
        </div>
        <!-- end 选择款式 -->
        <!-- SAMPLE BOX CONFIGURATION MODAL FORM-->
        <div class="modal fade" id="editImage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <form id="form_focus">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">维护图片</h4>
                        </div>
                        <div class="modal-body">

                            <div class="form-group  mrg-bt10" style="height: 100px">
                                <label class="control-label col-md-3" style="line-height: 34px;">
                                    <span class="required">*</span>
                                    图片：
                                </label>
                                <form>
                                    <div class="col-md-8">
                                        <div hidden-image></div>
                                        <div class="fileinput fileinput-new" data-provides="fileinput">
                                            <div class="image_preview_list" style="float: left;" id="imgs">
                                                <div class="fileinput-preview thumbnail image_preview_default" data-trigger="fileinput"
                                                     style="width: 120px; height: 90px;"></div>
                                            </div>
                                            <div style="float: left; margin-left: 5px; padding-top: 23px;" class="addnewimg" id="f_span">
                                                    <span class="btn btn-default btn-file" id="fir">
														<span class="fileinput-new" id="two">上传图片</span>
                                                    <span class="fileinput-exists">Change</span>
                                                    <input type="file" name="uploadFile" upload-file="detailImageUrl">
                                                    </span>
                                                <div class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100"
                                                     style="margin-bottom: 0px; margin-top: 10px;">
                                                    <div class="progress-bar progress-bar-success" style="width: 0%;"></div>
                                                </div>
                                            </div>

                                        </div>


                                    </div>
                                </form>

                            </div>
                            <div class="form-group  mrg-bt10">
                                <label class="control-label col-md-3" style="line-height: 34px;"> 链接： </label>
                                <div class="col-md-6">
                                    <textarea class="form-control" row=3 cols=15 name="linkurl" placeholder="请输入链接Url" style="resize: none"
                                              maxlength="200"></textarea>

                                </div>
                            </div>


                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary bt-save">保存</button>
                        </div>
                    </div>
                </form>

            </div>
        </div>
        <!-- /SAMPLE BOX CONFIGURATION MODAL FORM-->
        <div class="container">
            <div class="row">
                <div id="content" class="col-lg-12">
                    <!-- PAGE HEADER-->
                    <div class="row">
                        <div class="col-sm-12">
                            <div class="page-header">
                                <!-- STYLER -->

                                <!-- /STYLER -->
                                <!-- BREADCRUMBS -->
                                <ul class="breadcrumb">
                                    <li>
                                        <i class="fa fa-home"></i>
                                        <a href="index.html">首页</a>
                                    </li>
                                    <li>
                                        <a href="#">商品管理</a>
                                    </li>
                                    <li>维护商品</li>
                                </ul>
                                <!-- /BREADCRUMBS -->

                            </div>
                        </div>
                    </div>
                    <!-- /PAGE HEADER -->
                    <!-- SAMPLE -->
                    <div class="row">
                        <div class="col-md-12">
                            <!-- BOX -->
                            <div class="box border red" id="formWizard">
                                <input type="hidden" name="id">

                                <div class="box-body form">
                                    <form id="wizForm" action="#" class="form-horizontal">
                                        <input type="hidden" name="categoryId1">
                                        <input type="hidden" name="categoryId2">
                                        <input type="hidden" name="categoryId3">
                                        <input type="hidden" name="promotionPrice" value="0">
                                        <input type="hidden" name="sendType">
                                        <div class="wizard-form">
                                            <div class="wizard-content">
                                                <ul class="nav nav-pills nav-justified steps">


                                                    <li>
                                                        <a href="#baseInfo" data-toggle="tab" class="wiz-step active">
                                                            <span class="step-number">1</span>
                                                            <span class="step-name">
																	<i class="fa fa-check"></i>
																	编辑商品信息
																</span>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a href="#imageDetail" data-toggle="tab" class="wiz-step">
                                                            <span class="step-number">2</span>
                                                            <span class="step-name">
																	<i class="fa fa-check"></i>
																	编辑商品详情
																</span>
                                                        </a>
                                                    </li>
                                                </ul>
                                                <div id="bar" class="progress  progress-sm active" role="progressbar">
                                                    <div class="progress-bar progress-bar-warning"></div>
                                                </div>
                                                <div class="tab-content">
                                                    <!-- 第二步 -->
                                                    <div class="tab-pane" id="baseInfo">
                                                        <div class="form-group mrg-bt10" style="display: none;">
                                                            <label class="control-label col-md-2">商品分类：</label>
                                                            <div class="col-md-8 inline" id="categoryNames"></div>
                                                            <input type="hidden" name="categoryId"/>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品编码：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" name="productCode" placeholder="请输入商品编码"
                                                                       maxlength="50"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品名称：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" name="productName" placeholder="请输入商品名称"
                                                                       maxlength="50"/>
                                                                <input type="hidden" name="id"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>

                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                所属商家：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" name="supplierName" readonly="readonly">
                                                                <input type="hidden" name="supplierId">
                                                                <span class="error-span"></span>
                                                                <a href="javascript:;" class="btn btn-primary bt-selectSupplier">选择商家</a>
                                                            </div>

                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品品牌：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" name="brandName" readonly="readonly">
                                                                <input type="hidden" name="brandId">
                                                                <span class="error-span"></span>
                                                                <a href="javascript:;" class="btn btn-primary bt-selectBrand">选择品牌</a>
                                                            </div>

                                                        </div>
                                                        <div class="form-group mrg-bt10 category" style="display:none">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品分类
                                                            </label>
                                                            <div class="col-md-2">
                                                                <select class="form-control" id="category1_select">
                                                                    <option>请选择一级分类</option>

                                                                </select>
                                                            </div>
                                                            <div class="col-md-2">
                                                                <select class="form-control" id="category2_select">
                                                                    <option>请选择二级分类</option>
                                                                </select>
                                                            </div>
                                                            <div class="col-md-2">
                                                                <select class="form-control" name="categoryId" id="category3_select">
                                                                    <option value="">请选择三级分类</option>

                                                                </select>
                                                            </div>

                                                        </div>

                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品原价：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="原价" class="form-control width-50"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);"
                                                                       name="productOriginalPrice" maxlength="10"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品售价：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="销售价" class="form-control width-50"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);"
                                                                       name="productSalePrice" maxlength="10"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10" hidden="true">
                                                            <label class="control-label col-md-2">拼团价：</label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="拼团价" class="form-control width-50"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" value=0
                                                                       name="promotionPrice" maxlength="10"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <span class="required">*</span>
                                                            <label class="control-label col-md-2">分销价：</label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="分销价" class="form-control width-50"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" value=0
                                                                       name="p_distributionPrice" maxlength="10"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10 hide">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                新客价：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="新客价" class="form-control width-50"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" value=0
                                                                       name="newCustomPrice" maxlength="10"/>
                                                                <span class="">价格大于0表示用户可以享受优惠价</span>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10" id="vipRate_config">
                                                            <label class="control-label col-md-2">女王折扣：</label>
                                                            <div class="col-md-8 inline">
                                                                <select id="vipRate_select" name="vipRate" style="width: 50%">
                                                                    <option>选择折扣比例</option>
                                                                    <option value="0.00">0%</option>
                                                                    <option value="0.05">5%</option>
                                                                    <option value="0.10">10%</option>
                                                                    <option value="0.15">15%</option>
                                                                    <option value="0.20">20%</option>
                                                                    <option value="0.25">25%</option>
                                                                    <option value="0.30">30%</option>
                                                                    <option value="0.35">35%</option>
                                                                </select>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                会员价：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="会员价" readonly="readonly" class="form-control width-50" value=0
                                                                       name="vipPrice" maxlength="10"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div id='taxRate' hidden="hidden">
                                                            <div class="form-group mrg-bt10">
                                                                <label class="control-label col-md-2">
                                                                    <span class="required">*</span>
                                                                    增值税：（单位 %）
                                                                </label>
                                                                <div class="col-md-8 inline">
                                                                    <input type="text" placeholder="增值税" class="form-control width-50" value=0
                                                                           name="valueAddedTaxRate" maxlength="10"/>
                                                                    <span class="error-span"></span>
                                                                </div>
                                                            </div>
                                                            <div class="form-group mrg-bt10">
                                                                <label class="control-label col-md-2">
                                                                    <span class="required">*</span>
                                                                    消费税：（单位 %）
                                                                </label>
                                                                <div class="col-md-8 inline">
                                                                    <input type="text" placeholder="消费税" class="form-control width-50" value=0
                                                                           name="saleTaxRate" maxlength="10"/>
                                                                    <span class="error-span"></span>
                                                                </div>
                                                            </div>
                                                            <div class="form-group mrg-bt10">
                                                                <label class="control-label col-md-2">
                                                                    <span class="required">*</span>
                                                                    关税：（单位 %）
                                                                </label>
                                                                <div class="col-md-8 inline">
                                                                    <input type="text" placeholder="关税" class="form-control width-50" value=0 name="tariffRate"
                                                                           maxlength="10"/>
                                                                    <span class="error-span"></span>
                                                                    <span><font color="red">（消费税率+增值税率）/(1-消费税率) *0.7</font></span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品单位：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" placeholder="请输入单位" maxlength="10" class="form-control width-50"
                                                                       name="unitName" value="件"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                颜色/规格：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" maxlength="20" name="shortName"
                                                                       placeholder="请输入颜色/规格"/>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品款式：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input type="text" class="form-control width-50" name="groupName" readonly="readonly">
                                                                <input type="hidden" name="groupId">
                                                                <span class="error-span"></span>
                                                                <a href="javascript:;" class="btn btn-primary bt-selectGroup">选择款式</a>
                                                            </div>
                                                        </div>

                                                        <div class="form-group mrg-bt10" style="display: flex">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                销售平台：
                                                            </label>
                                                            <div class="col-md-4 inline">
                                                                <input type="checkbox" name="salesPlatform" value="Yiigoo">
                                                                <span>壹果</span>
                                                                <input type="checkbox" name="salesPlatform" value="Yijiadian">
                                                                <span>壹家店</span>

                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10" style="display: flex">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                退货支持：
                                                            </label>
                                                            <div class="col-md-4 inline">
                                                                <input type="checkbox" checked name="sevenReturn" value="1">
                                                                <span>7天无理由退货货</span>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10" style="display: none">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品风格：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <select id="style_select" name="style" style="width: 50%">

                                                                </select>
                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>


                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                分享返利：
                                                            </label>
                                                            <div class="col-md-8 inline">
                                                                <input name="shareRate" class="form-control" style="width:200px"
                                                                       onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" maxlength=4>


                                                                <span class="error-span"></span>
                                                            </div>
                                                        </div>

                                                        <div class="form-group mrg-bt10" style="display: none;">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品属性：
                                                            </label>
                                                            <div class="col-md-8 inline" id="basicAttribute"></div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="control-label col-md-2">销售属性：</label>
                                                            <div class="tagsList col-md-10 inline"></div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">商品卖点：</label>
                                                            <div class="col-md-10 inline">
                                                                <input type="text" placeholder="请输入商品卖点" maxlength="100" class="form-control width-50"
                                                                       name="sellingPoint"/>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">天猫ID：</label>
                                                            <div class="col-md-8 inline" style="display: flex;">
                                                                <input type="text" class="form-control" value="" name="tmallId" placeholder="请输入天猫商品ID"
                                                                       style="width: 50%"/>
                                                                <a href="javascript:;" class="btn btn-warning bt-loadimage" style="margin-left: 20px">加载图片</a>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10 creatSize" style="display: none">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                尺码大小：
                                                            </label>
                                                            <div class="col-md-8 sizelist">
                                                                <div style="float: left">
                                                                    <input type="hidden" class="form-control" style="width: 100px; float: left" maxlength="20"
                                                                           name="sizeName" placeholder="尺码/大小"/>
                                                                    <a href="javascript:;" class="btn btn-primary bt-addSize">添加尺码</a>
                                                                </div>

                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label  col-md-2">温馨提示：</label>
                                                            <div class="col-md-8 required">可单独修改SKU的销售价、会员价、原价，拼团价(拼团价默认取自选择的款式设置的拼团价)</div>
                                                        </div>
                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                SKU信息：
                                                            </label>
                                                        </div>
                                                        <div class="form-group">
                                                            <div class="col-md-12">
                                                                <table class="table table-bordered" id="skulist">
                                                                    <thead>
                                                                    <tr>
                                                                        <th style="display: none">id</th>
                                                                        <th>尺码/大小</th>
                                                                        <th>SKU编码</th>
                                                                        <th>售价</th>
                                                                        <th>拼团价</th>
                                                                        <th>会员价</th>
                                                                        <th>分销价</th>
                                                                        <th>原价</th>
                                                                        <th>成本</th>
                                                                        <th>库存</th>
                                                                        <th>操作</th>
                                                                    </tr>
                                                                    </thead>
                                                                    <tbody>

                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                        </div>
                                                        <div class="form-group mrg-bt10 uploadMainImage" style="line-height: 34px">
                                                            <label class="control-label col-md-2">
                                                                <span class="required">*</span>
                                                                商品图：
                                                            </label>
                                                            <div class="col-md-9" style="line-height: 34px; display: inline">
                                                                <label style="float: left">最多可以上传5张图片，建议尺寸：800*800px，大小不要超过300K。默认第一张为商品主图</label>
                                                                <div id="upload1" class="addnewimg" style="float: left; margin-left: 5px;">
                                                                        <span id="fir" class="btn btn-success btn-file">
																			<span id="two" class="fileinput-new">上传图片</span>
                                                                        <input type="file" upload-file="imageUrlProduct" multiple="" name="uploadFile">
                                                                        </span>
                                                                </div>
                                                                <div style="margin-top: 10px; width: 100px" aria-valuemax="100" aria-valuemin="0"
                                                                     role="progressbar" class="progress progress-striped active">
                                                                    <div style="width: 0%;" class="progress-bar progress-bar-success"></div>
                                                                </div>
                                                            </div>
                                                        </div>


                                                        <div class="form-group mrg-bt10">
                                                            <label class="control-label col-md-1"></label>
                                                            <div class="col-md-9 dd" id="nestable2" style="margin-left: 20px">
                                                                <ol class="dd-list">

                                                                </ol>
                                                            </div>

                                                        </div>
                                                    </div>

                                                    <!-- /第二步 -->
                                                    <!-- 第三步 -->
                                                    <div class="tab-pane" id="imageDetail">
                                                        <div class="form-group" style="line-height: 34px">
                                                            <label class=" col-md-7" style="line-height: 34px; text-align: left">图文详情：建议图片宽度800px，大小不要超过300K。向左拖动图片进行排序，点击图片编辑链接</label>
                                                            <div id="upload2" class="addnewimg col-md-1" style="margin-left: 5px;">
                                                                    <span id="fir" class="btn btn-success btn-file">
																		<span id="two" class="fileinput-new">上传图片</span>
                                                                    <input type="file" upload-file="detailUrlProduct" multiple="" name="uploadFile">
                                                                    </span>
                                                            </div>
                                                            <div style="margin-top: 10px; width: 100px" aria-valuemax="100" aria-valuemin="0" role="progressbar"
                                                                 class="progress progress-striped active">
                                                                <div style="width: 0%;" class="progress-bar progress-bar-success"></div>
                                                            </div>
                                                            <div class="fromImages col-md-1">
                                                                <a data-toggle="modal" class="btn btn-warning">
                                                                    <i class="fa  fa-plus-square-o"></i> 从图库选择
                                                                </a>
                                                            </div>

                                                        </div>

                                                        <div class="col-md-8">
                                                            <!-- BOX -->


                                                            <div class="col-md-9 dd" id="detailImage" style="margin-left: 20px">
                                                                <ol class="dd-list">

                                                                </ol>
                                                            </div>


                                                            <!-- /BOX -->
                                                        </div>
                                                    </div>
                                                    <!-- /第三步 -->
                                                </div>
                                            </div>
                                            <div class="wizard-buttons" style="margin-top: 80px;">
                                                <div class="row">
                                                    <div class="col-md-12">
                                                        <div class="col-md-offset-3 col-md-9">
                                                            <a href="javascript:;" class="btn btn-default prevBtn">
                                                                <i class="fa fa-arrow-circle-left"></i> 上一步
                                                            </a>
                                                            <a href="javascript:;" class="btn btn-primary nextBtn">
                                                                下一步
                                                                <i class="fa fa-arrow-circle-right"></i>
                                                            </a>
                                                            <a href="javascript:;" class="btn btn-success submitBtn">
                                                                保存
                                                                <i class="fa fa-arrow-circle-right"></i>
                                                            </a>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <!-- /BOX -->
                        </div>
                    </div>
                    <!-- /SAMPLE -->

                    <div class="footer-tools">
                            <span class="go-top">
								<i class="fa fa-chevron-up"></i>
								Top
							</span>
                    </div>
                </div>
                <!-- /CONTENT-->
            </div>
        </div>
    </div>
</section>
<!--/PAGE -->
<!-- JAVASCRIPTS -->
<!-- Placed at the end of the document so the pages load faster -->

<!-- JQUERY UI-->
<script src="../../js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
<!-- BOOTSTRAP -->
<script src="../../bootstrap-dist/js/bootstrap.js"></script>
<!-- SLIMSCROLL -->
<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js"></script>
<script type="text/javascript" src="../../js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js"></script>
<!-- BLOCK UI -->
<script type="text/javascript" src="../../js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
<!--bootbox-->
<script type="text/javascript" src="../../js/bootbox/bootbox.min.js"></script>
<!-- AUTOSIZE -->
<script type="text/javascript" src="../../js/autosize/jquery.autosize.min.js"></script>
<!-- spinner -->
<script src="../../js/spinner/spin.js"></script>
<!-- bootstrap-fileupload -->
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload.min.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-process.min.js"></script>
<script type="text/javascript" src="../../js/jquery-upload/js/jquery.fileupload-validate.min.js"></script>

<!-- INPUT MASK -->
<script type="text/javascript" src="../../js/bootstrap-inputmask/bootstrap-inputmask.min.js"></script>

<!-- SELECT2 -->
<script type="text/javascript" src="../../js/select2/select2.min.js"></script>
<!-- DATA TABLES -->
<script type="text/javascript" src="../../js/datatables/bootstrap-select.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-bootstrap.js"></script>
<script type="text/javascript" src="../../js/datatables/datatable-tabletools.js"></script>
<script type="text/javascript" src="../../js/datatables/fnAddTr.js"></script>
<!-- UNIFORM -->
<script type="text/javascript" src="../../js/uniform/jquery.uniform.min.js"></script>
<!-- WIZARD -->
<script src="../../js/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
<!-- WIZARD -->
<script src="../../js/jquery-validate/jquery.validate.min.js"></script>
<script src="../../js/jquery-validate/additional-methods.min.js"></script>
<script src="../../js/bootstrap-wizard/form-wizard.js"></script>
<!-- NESTABLE LISTS -->
<script type="text/javascript" src="../../js/nestable/jquery.nestable.min.js"></script>
<!-- COOKIE -->
<script type="text/javascript" src="../../js/jQuery-Cookie/jquery.cookie.min.js"></script>
<!-- CUSTOM SCRIPT -->
<script src="../../js/script.js"></script>

<script src="../../js/Sortable.min.js"></script>
<script>
    var AddProduct = function () {
        var id = null,
            flag, groupId, productCode = "",
            $mainDataTable;

        var loadGroup = function () {
            var q = $("[name=gName]").val();
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/group/searchGroup.do?start=0&limit=20&groupType=Web&q=" + q,
                async: true,
                success: function (result) {
                    console.log(result);
                    if (result != null) {
                        var data = eval(result.data);
                        var tr = "";
                        $("#tb_group").empty();
                        $.each(data, function (index, item) {
                            tr = "<tr data_id=" + item.id + "><td>" + item.groupName + "</td></tr>";
                            $("#tb_group").append(tr);
                        });
                        $("#tb_group tr").dblclick(function () {
                            $("[name=groupName]").val($(this).find("td:eq(0)").html())
                            $("[name=groupId]").val($(this).attr("data_id"));
                            $("#editGroup").modal("hide");

                        })
                    }
                }
            });
        };
        var loadBrand = function () {
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/brand/searchBrandList.do?start=0&limit=20&supplierId=" + $("[name=supplierId]").val(),
                async: true,
                success: function (result) {
                    if (result != null) {
                        var data = eval(result);
                        $("#tb_brand").empty();
                        var tr = "";
                        $.each(data, function (index, item) {
                            tr = "<tr data_id=" + item.id + "><td>" + item.brandName + "</td></tr>";
                            $("#tb_brand").append(tr);
                        });
                        $("#tb_brand tr").dblclick(function () {
                            $("[name=brandName]").val($(this).find("td:eq(0)").html())
                            $("[name=brandId]").val($(this).attr("data_id"));
                            $("#editBrand").modal("hide");

                        })

                    }
                }
            });
        };
        var loadStyle = function () {
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/style/searchStyleList.do?start=0&limit=20&q=" + q,
                async: true,
                success: function (result) {
                    if (result != null) {
                        var data = eval(result);
                        var option = "<option></option>";
                        $.each(data, function (index, item) {
                            option += "<option value='" + item.id + "'>" +
                                item.styleName + "</option>";
                        });
                        $("#style_select").empty().append(option).select2({
                            placeholder: "选择风格"
                        });
                        $("#s2id_style_select").addClass("width_100");
                    }
                }
            });
        };
        var loadSupplier = function () {
            var q = $("[name=txt_supplierName]").val();
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/store/searchSupplierList.do?start=0&limit=20&q=" + q,
                async: true,
                success: function (result) {
                    if (result != null) {
                        var data = eval(result);
                        $("#tb_supplier").empty();
                        var tr = "";
                        $.each(data, function (index, item) {
                            tr = "<tr data_id=" + item.id + " sendType='" + item.sendType + "'><td>" + item.supplierName + "</td></tr>";
                            $("#tb_supplier").append(tr);
                        });
                        $("#tb_supplier tr").dblclick(function () {
                            $(".category").hide()
                            $("[name=supplierName]").val($(this).find("td:eq(0)").html())
                            $("[name=supplierId]").val($(this).attr("data_id"));
                            var sendType = $(this).attr("sendType");
                            $("[name=sendType]").val(sendType);
                            if ($(this).attr("data_id") == 48) {
                                $("#taxRate").show();
                            } else {
                                $("#taxRate").hide();
                            }

                            //如果sendType=="SupplierSend" 第三方商家发货，则页面显示分类，必选
                            if (sendType == "SupplierSend") {
                                $(".category").show()
                                loadParentCategory();
                            }

                            $("#editSupplier").modal("hide");

                        })
                    }
                }
            });
        };

        //设置主图或者删除
        var handleHover = function () {
            $('.filter-content').hover(
                function () {
                    var hoverContent = $(this).children(
                        '.hover-content');
                    hoverContent.removeClass('fadeOut').addClass(
                        'animated fadeIn').show();
                },
                function () {
                    var hoverContent = $(this).children(
                        '.hover-content');
                    hoverContent.removeClass('fadeIn').addClass(
                        'fadeOut').hide();
                });
        };
        //添加一个尺码
        var addSize = function () {
            var size = $("input[name=sizeName]").val().trim();
            /* if (size == "") {
                $.alert("请先设置尺码信息");
                return false;
            } */
            var isExists = false;
            //判断尺码是否已经存在
            /*$(".table tbody tr").each(function() {
                if ($(this).find("input:eq(0)").val() == size) {
                    $.alert("输入尺码已经存在");
                    isExists = true;
                    return false;
                }

            });
            if (isExists)
                return false;*/

            var salesPrice = $("input[name=productSalePrice]").val();
            var orgPrice = $("input[name=productOriginalPrice]").val();
            var promotionPrice = $("input[name=promotionPrice]").val();
            var vipPrice = $("input[name=vipPrice]").val();
            var distributionPrice = $("input[name=p_distributionPrice]").val();
            //根据productCode 自动生成skuCode
            /* var skuCode=$("[name=productCode]").val();
            if(skuCode!=""){
                var i=$("#skulist tbody tr").length+1;
                skuCode=skuCode+i;
            } */
            addSizeHtml("", "", size, salesPrice, orgPrice, 0, "",
                promotionPrice, "Valid", vipPrice, 0, distributionPrice);
        };
        //上传商品图片
        var fileUpLoad = function () {
            $(".uploadMainImage").find('.progress-bar').css('width', '0%');
            $(".uploadMainImage").find('.progress').hide();
            $("[upload-file=imageUrlProduct]")
                .fileupload({
                    url: App.getContextPath() +
                        "admin/file/uploadImage.do",
                    formData: {
                        fileType: "ProductDetailImage,ProductListImage,ProductShoppingCartImage"
                    },
                    dataType: 'json',
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
                    iframe: true,
                    maxNumberOfFiles: 5,
                    autoUpload: true,
                    start: function (e) {
                        $(".uploadMainImage").find('.progress')
                            .fadeIn(300);
                        return true;
                    },
                    done: function (e, data) {
                        var result = data.result;
                        if (result.message != "") {
                            $.alert(result.message)
                            return false;
                        } else {
                            addMainImageHtml(result.fileUrl, "");
                            $('#nestable2').nestable({
                                maxDepth: 1
                            });
                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded /
                            data.total * 100, 10);
                        $(".uploadMainImage").find(
                            '.progress-bar').css('width',
                            progress + '%');
                    }
                }).on(
                'fileuploaddone',
                function (e, data) {
                    $(".uploadMainImage").find(".progress")
                        .fadeOut(300);

                });
        };

        //上传商品详情页图片
        var detailFileUpLoad = function () {
            $("#imageDetail").find('.progress-bar').css('width', '0%');
            $("#imageDetail").find('.progress').hide();
            $("[upload-file=detailUrlProduct]")
                .fileupload({
                    url: App.getContextPath() +
                        "admin/file/uploadImage.do",
                    formData: {
                        fileType: "ProductDetailImage"
                    },
                    dataType: 'json',
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
                    iframe: true,
                    start: function (e) {
                        $(".fromImages").hide();
                        $("#imageDetail").find('.progress')
                            .fadeIn(300);
                        return true;
                    },
                    autoUpload: true,
                    done: function (e, data) {

                        var result = data.result;
                        if (result.message != "") {
                            $.alert(result.message)
                            $(".fromImages").show();
                            return false;
                        } else {
                            addDetailHtml(result.fileUrl);
                            setTimeout(function () {
                                $(".fromImages").show();
                            }, 200);

                        }
                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded /
                            data.total * 100, 10);
                        $("#imageDetail").find('.progress-bar')
                            .css('width', progress + '%');
                    }
                }).on('fileuploaddone', function (e, data) {
                $("#imageDetail").find(".progress").fadeOut(300);

            });
        };

        //保存商品
        var saveProduct = function (e) {
            var p = {};
            if (!$("input[name=vipPrice]").val()) {
                $.alert("请选择女王价比例");
                return false;
            }
            if (!$("input[name=groupId]").val()) {
                $.alert("请选择商品款式");
                return false;
            }
            if (!$("input[name=supplierId]").val()) {
                $.alert("请选择商家");
                return false;
            }
            if (!$("input[name=brandId]").val()) {
                $.alert("请选择品牌");
                return false;
            }
            //若sendTye==SupplierSend 表示第三方商家发货，则必选选择分类
            if ($("[name=sendType]").val() == "SupplierSend") {
                if ($("#category3_select").val() == "") {
                    $.alert("第三方商家发货，必选选择商品分类");
                    return false;
                } else {
                    p.categoryId = $("#category3_select").val();
                    p.categoryNames = $("#category1_select option:selected").text() + "," + $("#category2_select option:selected").text() + "," + $("#category3_select option:selected").text();
                    p.basicAttribute = "品牌团购";


                }
            } else {
                p.categoryId = $("[name=categoryId]").val();
                p.categoryNames = $("#categoryNames").text();
            }

            e.preventDefault();
            if ($("#imageDetail").find("img").length == 0) {
                $.alert("请至少上次一张商品详情图");
                return false;
            }
            var isExists = false;
            var sizeArray = [];

            $.blockUI();
            var flag = $.getUrlParam("flag");
            p.sendType = $("[name=sendType]").val()
            if (flag != "group")
                p.id = $("input[name=id]").val();
            p.productCode = $("input[name=productCode]").val();
            p.productName = $("input[name=productName]").val();
            p.productOriginalPrice = $("input[name=productOriginalPrice]").val();
            p.productSalePrice = $("input[name=productSalePrice]").val();
            p.newCustomPrice = 0; //$("input[name=newCustomPrice]").val();
            p.promotionPrice = $("input[name=promotionPrice]").val();
            p.vipPrice = $("input[name=vipPrice]").val();
            p.shortName = $("input[name=shortName]").val();
            p.brandId = $("[name=brandId]").val();
            p.groupId = $("[name=groupId]").val();

            p.supplierId = $("[name=supplierId]").val();
            p.styleId = 1; //$("#style_select").val();
            p.unitName = $("input[name=unitName]").val();
            p.promotionType = $("#promotionType_select").val();
            p.tmallId = $("[name=tmallId]").val();
            p.shareRate = $("[name=shareRate]").val();
            p.basicAttribute = $("#basicAttribute").text();

            p.sellingPoint = $("[name=sellingPoint]").val();
            p.valueAddedTaxRate = $("[name=valueAddedTaxRate]").val();
            p.tariffRate = $("[name=tariffRate]").val();
            p.saleTaxRate = $("[name=saleTaxRate]").val();
            p.distributionPrice = $("input[name=p_distributionPrice]").val();
            p.sevenReturn = $("[name=sevenReturn]").prop("checked");

            p.productImages = [];
            p.ygSkus = [];
            p.ygSkus.stock = [];
            var tags = [];
            $("[name=tags]:checked").each(function (i) {
                tags.push($(this).next().text());
            });
            p.tags = tags.join(",");
            var salesPlatforms = [];
            $("[name=salesPlatform]:checked").each(function (i) {
                salesPlatforms.push($(this).val());
            });
            p.salesPlatform = salesPlatforms.toString();

            //获取主图
            $("#nestable2").find("img").each(function (index, item) {
                var img = {};
                img.imagePath = $(this).src;
                if (index == 0)
                    img.isMain = 1;
                else
                    img.isMain = 0;
                img.id = $(this).attr("pid");
                img.sortNum = index++;
                img.imagePath = $(this).attr("src");
                p.productImages.push(img);

            });
            //获取sku
            var i = 0; //sku状态个数统计
            $("#skulist tbody tr").each(
                function () {
                    var sku = {};
                    if (flag != "group")
                        sku.id = $(this).find("td:eq(0)").html();
                    sku.skuCode = $(this).find("input[name=skuCode]")
                        .val();
                    sku.sizeName = $(this).find("input:eq(0)").val()
                        .trim();
                    sku.salesPrice = $(this).find(
                        "input[name=salesPrice]").val();
                    sku.sourceSalesPrice = $(this).find(
                        "input[name=orgPrice]").val();
                    sku.promotionPrice = $(this).find(
                        "input[name=promotionPrice]").val();
                    sku.newCustomPrice = 0; //$(this).find("input[name=newCustomPrice]").val();
                    sku.vipPrice = $(this).find("input[name=vipPrice]")
                        .val();
                    sku.distributionPrice = $(this).find("input[name=distributionPrice]")
                        .val();
                    sku.costPrice = $(this).find(
                        "input[name=costPrice]").val();
                    sku.status = $(this).find(".bt-del-size").attr(
                        "status");
                    if (sku.status == "Valid")
                        i++;
                    var stock = {};
                    stock.id = $(this).find("input[name=stockNum]")
                        .attr("id");
                    stock.skuCode = sku.skuCode;
                    stock.amount = $(this).find("input[name=stockNum]")
                        .val();
                    sku.stock = stock;
                    p.ygSkus.push(sku);

                });
            //获取详情图
            var detailImg = [];
            $("#imageDetail").find("img").each(function () {
                var path = $(this).attr("src");
                var link = $(this).attr("linkurl");
                if (link != "")
                    path = path + ";" + link;
                detailImg.push(path);
            });
            p.detailImagePath = detailImg.toString();
            ///判断sku 的状态是否是有效的
            if (i == 0) {
                $.unblockUI();
                $.alert("请添加有效的SKU");
                return false;
            }
            $.ajax({
                type: "post",
                url: App.getContextPath() +
                    "admin/product/saveProduct.do",
                data: $.param({
                    product: JSON.stringify(p),
                    productCode: productCode
                }),
                async: true,
                success: function (result) {
                    $.unblockUI();
                    if (result.type == "error") {
                        $.alert(result.extra);
                    } else {
                        $.alert("保存成功");

                        location.href = "product_list.html";
                    }
                },
                error: function (result) {
                    $.unblockUI();
                    $.alert("出错了,请检查一下必输项");
                }
            });
        }

        //根据产品id 获取产品信息
        var getProductInfo = function (productId) {
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/product/getProductById.do",
                data: {
                    id: productId
                },
                async: true,
                success: function (result) {
                    setProduct(result);
                }
            });
        };

        var setProduct = function (p) {
            var salePrice = p.productSalePrice;
            if (p.promotionPrice != 0)
                salePrice = p.promotionPrice;
            if (p.vipPrice && p.vipPrice > 0) {
                var i = parseFloat(salePrice) -
                    parseFloat(p.vipPrice);
                i = (i / salePrice).toFixed(2);

                $("#vipRate_select").select2("val", i);

            }
            if (flag == "edit") {
                $("input[name=id]").val(p.id);

            }
            $("[name=sevenReturn]").attr("checked", p.sevenReturn)


            $("[name=valueAddedTaxRate]").val(p.valueAddedTaxRate);
            $("[name=saleTaxRate]").val(p.saleTaxRate);
            $("[name=tariffRate]").val(p.tariffRate);
            if (p.supplierId == 48) {
                $("#taxRate").show();
            } else {
                $("#taxRate").hide();
            }
            if (p.sendType == "SupplierSend") {
                loadParentCategory();
                getParentsCategory(p.categoryId);//设置分类
                $(".category").show();
            }

            $("[name=categoryId]").val(p.categoryId);
            $("input[name=productCode]").val(p.productCode);
            productCode = p.productCode;
            $("input[name=productName]").val(p.productName);
            $("input[name=productOriginalPrice]").val(
                p.productOriginalPrice);
            $("input[name=productSalePrice]").val(p.productSalePrice);
            // $("input[name=newCustomPrice]").val(p.newCustomPrice);
            $("input[name=promotionPrice]").val(p.promotionPrice);
            $("input[name=vipPrice]").val(p.vipPrice);
            $("input[name=p_distributionPrice]").val(p.distributionPrice);
            $("input[name=shortName]").val(p.shortName);
            $("[name=tmallId]").val(p.tmallId);
            $("[name=brandName]").val(p.brandName);
            $("[name=brandId]").val(p.brandId);
            $("[name=supplierId]").val(p.supplierId);
            $("[name=supplierName]").val(p.supplierName);
            $("[name=sendType]").val(p.sendType)

            $("[name=groupName]").val(p.groupName);
            $("[name=groupId]").val(p.groupId);
            $("[name=sellingPoint]").val(p.sellingPoint);
            //$("#group_select").select2("val", p.groupId);
            //$("[name=tags]").val(p.tags);
            if (p.tags && p.tags.length > 0) {
                $.each(p.tags.split(","), function (index, item) {
                    var m = item;
                    $.each(tagsList, function (index, item) {
                        if (m == item.attributeName) {
                            $(".tagsList").find("input[value='" + m + "']")
                                .attr("checked", true)
                        }
                    })
                });
            }

            $.each(p.salesPlatform.split(","), function (index, item) {
                $("input[value='" + item + "']").attr("checked", true)
            });

            if (flag != "copy") {

                $("#promotionType_select").select2("val", p.promotionType);
                $("[name=shareRate]").val(p.shareRate);
            }
            $("#style_select").select2("val", p.styleId);
            $("input[name=unitName]").val(p.unitName);

            if (p.categoryNames) {
                $("#categoryNames").text(p.categoryNames);
                $("#categoryNames").parent().show();
            }
            if (p.basicAttribute && p.basicAttribute != "") {
                $("#basicAttribute").text(p.basicAttribute);
                $("#basicAttribute").parent().show();
            }
            $("[name=shareRate]").val(p.shareRate);
            $("#supplier_select").select2("val", p.supplierId);
            //根据sku 设置尺码
            //对商品尺码排序
            p.ygSkus.sort(function (a, b) {
                return a.id - b.id
            });

            $.each(p.ygSkus,
                function (index, item) {
                    addSizeHtml(item.id, item.skuCode, item.sizeName,
                        item.salesPrice, item.sourceSalesPrice,
                        item.stock.amount, item.stock.id,
                        item.promotionPrice, item.status,
                        item.vipPrice, 0, item.distributionPrice);
                });
            //对商品主图排序
            p.productImages.sort(function (a, b) {
                return a.sortNum - b.sortNum
            });
            //设置商品主图
            $.each(p.productImages, function (index, item) {
                addMainImageHtml(item.imagePath, item.id);
            });

            //设置商品详情图
            $.each(p.detailImagePath.split(','), function (index, item) {
                addDetailHtml(item);
            });

            if (flag == "group") {
                $("input[name=shortName]").val("");
                $("input[name=productName]").val("");
                $("[name=productCode]").val("");
                $("input[name=id").val("");
                //$("#nestable2").find("li").remove();
                $(".media-list").html("");
                $("[name=skuCode]").val("");
                $("#skulist").find("tbody").empty();
                $(".creatSize").show();
            }
            if (p.supplierId != 1 && flag == "edit") {
                $("[name=productCode]").attr("readonly", "readonly");
                $("[name=skuCode]").attr("readonly", "readonly");
                $("[name=costPrice]").attr("readonly", "readonly");
                $(".creatSize").show();


            }
            setTimeout(function () {
                $('#nestable2').nestable();
            }, 3000);

        }

        //添加Size
        var addSizeHtml = function (skuid, skuCode, size, salesPrice,
                                    orgPrice, stockNum, stockid, newCustomPrice, skustatus,
                                    vipPrice, costPrice, distributionPrice) {
            /* var sizehtml = '<div class="alert alert-block alert-info fade in input-size" style="height: 40px;margin-bottom:0px;width:auto;">' +
                '<a aria-hidden="true" href="#" data-dismiss="alert" class="bt-del-size close">×</a>' +
                '<p style="min-width:80px"><strong>' + size + '</strong></p></div>';
            $(".sizelist").append(sizehtml); */
            var r = skustatus == "Delete" ? "readonly" : "";
            var readOnly = skuid == "" && id == null ? "readonly" : "";
            readOnly = flag == "group" ? "readonly" : "";
            var isPromotionPrice = $("[name=promotionPrice]").val() == 0 ? "readonly" :
                "";
            var statutxt = "删除";
            var statusclass = "btn-danger";
            if (skuid != "") {
                statutxt = skustatus == "Delete" ? "启用" : "禁用";
                statusclass = skustatus == "Delete" ? "btn-warning" :
                    "btn-danger";
            }
            //添加一个table 行
            var trhtml = '<tr status="Valid"><td style="display:none">' +
                skuid +
                '</td><td><input type="text" class="form-control" ' + r + ' ' + readOnly + ' maxlength=50 value="' + size + '"/></td><td><input type="text" name="skuCode" ' + r + ' ' + readOnly + ' class="form-control" style="width:100px;" maxlength="20" placeholder="SKU编码" value="' + skuCode + '"/></td>' +
                '<td><input type="text" name="salesPrice" class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                salesPrice +
                '" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" maxlength="10" placeholder="售价"/></td>' +
                '<td><input type="text" name="promotionPrice" ' +
                isPromotionPrice +
                ' class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                newCustomPrice +
                '" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" maxlength="10" placeholder="新客价"/></td>' +
                '<td><input type="text" name="vipPrice"  class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                vipPrice +
                '" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" maxlength="10" placeholder="会员价"/></td>' +
                '<td><input type="text" name="distributionPrice"  class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                distributionPrice +
                '" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" maxlength="10" placeholder="分销价"/></td>' +
                '<td><input type="text" name="orgPrice" class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                orgPrice +
                '" maxlength="10" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" placeholder="原价"/></td>' +
                '<td><input type="text" name="costPrice" class="form-control" ' +
                r +
                ' style="width:60px;" value="' +
                costPrice +
                '" maxlength="10" onkeypress="return $.IsDecimal(event);" onblur="return $.IsMoney(this);" placeholder="成本"/></td>' +
                '<td><input type="text" name="stockNum" class="form-control" ' +
                r +
                ' style="width:60px;" maxlength="10" onkeypress="return $.IsNum(event);" onblur="return $.IsNaN(this);" placeholder="库存" value="' +
                stockNum +
                '" id="' +
                stockid +
                '"/></td><td><a class="btn ' + statusclass + ' bt-del-size" status=' + skustatus + ' href="javascript:;">' +
                statutxt + '</a></td></tr>';
            $(".table tbody").append(trhtml);
            $("input[name=sizeName]").val('');
            //设置内容的高度
            $(".wizard-content").css("height",
                $(".wizard-content").height() + 52);
            //删除size 时将数据行删除
            $(".bt-del-size").unbind("click").bind(
                "click",
                function () {
                    var s = $(this).closest("tr").find("td:eq(0)")
                        .html();
                    if (s.length > 0) {
                        if ($(this).html() == "禁用") {
                            $(this).closest("tr").find("input").attr(
                                "readonly", "readonly");
                            $(this).html("启用")
                                .removeClass("btn-danger")
                                .addClass("btn-warning");
                            $(this).attr("status", "Delete");
                        } else {
                            $(this).closest("tr").find("input")
                                .removeAttr("readonly");
                            $(this).html("禁用").removeClass(
                                "btn-warning").addClass(
                                "btn-danger");
                            $(this).attr("status", "Valid");
                        }
                    } else {
                        $(this).closest("tr").remove();
                    }
                });
            //注册SKU验证事件
            $("[name=skuCode]").unbind("blur").bind("blur", checkSKUCode);
            $("#skulist")
                .off("blur")
                .on(
                    "[name=salesPrice],[name=promotionPrice]",
                    "blur",
                    function () {
                        var vip = $("#vipRate_select").val();
                        var p = 0;
                        if ($(this).closest("tr").find(
                            "[name=promotionPrice]").val() > 0) //取拼团价
                        {
                            p = $(this).closest("tr").find(
                                "[name=promotionPrice]").val();

                            $(this)
                                .closest("tr")
                                .find("[name=vipPrice]")
                                .val(
                                    (parseFloat(p) * parseFloat(vip))
                                        .toFixed(0))

                        } else {
                            p = $(this).closest("tr").find(
                                "[name=salesPrice]").val();

                            $(this)
                                .closest("tr")
                                .find("[name=vipPrice]")
                                .val(
                                    (parseFloat(p) * parseFloat(vip))
                                        .toFixed(0))
                        }
                    });
            $("#skulist")
                .off("blur")
                .on(
                    "blur",
                    "[name=salesPrice],[name=promotionPrice]",
                    function () {
                        var vip = $("#vipRate_select").val();
                        var p = 0;
                        if ($(this).closest("tr").find(
                            "[name=promotionPrice]").val() > 0) //取拼团价
                        {
                            p = $(this).closest("tr").find(
                                "[name=promotionPrice]").val();

                            $(this)
                                .closest("tr")
                                .find("[name=vipPrice]")
                                .val(
                                    (parseFloat(p) * parseFloat(1 - vip))
                                        .toFixed(0))

                        } else {
                            p = $(this).closest("tr").find(
                                "[name=salesPrice]").val();
                            $(this)
                                .closest("tr")
                                .find("[name=vipPrice]")
                                .val(
                                    (parseFloat(p) * parseFloat(1 - vip))
                                        .toFixed(0))
                        }
                    });

        };

        //添加商品主图
        var addMainImageHtml = function (url, id) {
            var i = "imgage" +
                ($('#nestable2').find(".dd-list").find("li").length + 1);
            var imgs = '<li class="dd-item filter-content" data-id="' + i + '"><img class="dd-handle" width="180px" height="180px" src="' + url + '" pid="' + id + '"/>' +
                '<div class="hover-content"><a class="btn btn-danger hover-link colorbox-button btn-del-image"  title="删除"><i class="fa fa-times fa-1x"></i></a></div></li>';
            $('#nestable2').find(".dd-list").append(imgs);

            handleHover();
            $(".btn-setMain").unbind("click").bind("click", function () {
                //已经设置主图的取消设置
                $(".bt-main").hide();
                $(this).prev().show();
                $(this).hide();
                $(this).next().hide();
            });
            $(".btn-del-image").click(function () {
                $(this).closest("li").remove();
                $("#upload1").show();
            });

            //如果当前图片个数已经达到5个隐藏上传按钮
            if ($('#nestable2').find(".dd-list li").length == 5 &&
                flag != "group") {
                $("#upload1").hide();
            }
        };
        //添加商品详情图
        var i = 0;
        var addDetailHtml = function (url) {
            i++;
            var urlArr = url.split(";"),
                linkUrl = "";
            if (urlArr.length > 1)
                linkUrl = urlArr[1];
            var imgUrl = urlArr[0];
            var id = "image" + i;
            var imgs = '<li class="dd-item filter-content" data-id="' + id + '"><img class="dd-handle" id="' + id + '" width="414px" src="' + imgUrl + '" linkurl="' + linkUrl + '"/><div class="hover-content"><a class="btn btn-success bt-edit hover-link"><i class="fa fa-edit fa-1x"></i></a><a class="btn btn-danger hover-link colorbox-button btn-del-image"  title="删除"><i class="fa fa-times fa-1x"></i></a></div></li>';
            $('#detailImage').find(".dd-list").append(imgs);
            $('#detailImage').find(".dd-list").on("click",
                ".btn-del-image",
                function () {
                    $(this).closest("li").remove();
                });
            $('#detailImage')
                .find(".dd-list")
                .find(".filter-content")
                .hover(
                    function () {
                        var hoverContent = $(this).children(
                            '.hover-content');
                        hoverContent.removeClass('fadeOut')
                            .addClass('animated fadeIn').show();
                    },
                    function () {
                        var hoverContent = $(this).children(
                            '.hover-content');
                        hoverContent.removeClass('fadeIn')
                            .addClass('fadeOut').hide();
                    });
            $('#detailImage').nestable();
            $("#detailImage").find(".bt-edit").unbind("click")
                .click(
                    function () {
                        id = $(this).closest("li").find("img")
                            .attr("id");
                        var url = $(this).closest("li").find("img")
                            .attr("src");
                        var link = $(this).closest("li")
                            .find("img").attr("linkurl");
                        var imageId = $(this).closest("li").find(
                            "img").attr("id");

                        $("#editImage").find("[name='imagePath']")
                            .val(url);
                        $("#editImage").find(
                            ".image_preview_default").empty()
                            .append("<img src='" + url + "'/>");

                        $("[name=linkurl]").val(link);
                        $(".progress").hide();
                        upLoadImg();
                        $(".bt-save").unbind("click").click(
                            function () {
                                url = $("#editImage").find(
                                    "[name='imagePath']")
                                    .val();
                                link = $("#editImage").find(
                                    "[name='linkurl']")
                                    .val();

                                $("#" + id).attr("src", url);
                                $("#" + id).attr("linkurl",
                                    link);
                                $("#editImage").modal("hide");
                            });
                        $("#editImage").modal("show");

                    });
        };

        //检验商品编码
        var checkProductCode = function () {
            var productCode = $("[name=productCode]").val();
            if (productCode != "") {
                $.ajax({
                    type: "get",
                    url: App.getContextPath() +
                        "admin/product/checkProductCode.do",
                    data: {
                        productCode: productCode,
                        id: $("[name=id]").val()
                    },
                    async: true,
                    success: function (result) {
                        if (result == true) {
                            $.alert("商品编码" + $("[name=productCode]").val() +
                                "已存在");
                            $("[name=productCode]").val("");
                            return false;
                        }
                        return true;
                    }
                });
            }
        }
        var getSizeList = function () {
            $(".table tbody").html("");
            $.ajax({
                type: "get",
                url: App.getContextPath() +
                    "admin/adminsku/getSkuList.do",
                data: {
                    productCode: $("input[name=productCode]")
                        .val()
                },
                async: true,
                success: function (result) {
                    $("#categoryNames").text('');
                    $("#basicAttribute").text('');
                    $("#categoryNames").parent().hide();
                    $("#basicAttribute").parent().hide();
                    if (result.length > 0) {
                        $("input[name=productName]").val(result[0].productName);
                        $("input[name=shortName]").val(result[0].color);
                        var salesPrice = $(
                            "input[name=productSalePrice]")
                            .val();
                        var orgPrice = $(
                            "input[name=productOriginalPrice]")
                            .val();

                        var newCustomPrice = $(
                            "input[name=newCustomPrice]").val();
                        var vipPrice = $("input[name=vipPrice]")
                            .val();
                        $.each(result, function (index, item) {

                            addSizeHtml("", item.skuCode,
                                item.sizeName, salesPrice,
                                orgPrice, 0, "",
                                newCustomPrice, "Valid",
                                vipPrice, 0, 0);
                        })
                        $("[name=supplierId]").val(1);
                        $("[name=supplierName]").val("壹果");
                        $("[name=sendType]").val("StockSend");
                        $("[name=brandId]").val(4);
                        $("[name=brandName]").val("壹果");
                        //checkProductCode();
                        if (result[0].categoryNames &&
                            result[0].categoryNames != "") {
                            $("#categoryNames").text(
                                result[0].categoryNames);
                            $("[name=categoryId]").val(
                                result[0].categoryId)
                            $("#categoryNames").parent().show();

                        } else {
                            $.alert("商品编码没有维护分类");
                            return;
                        }
                        if (result[0].basicAttribute &&
                            result[0].basicAttribute != "") {
                            $("#basicAttribute").text(
                                result[0].basicAttribute);
                            $("#basicAttribute").parent().show();
                        }
                    } else {
                        if ($("#supplier_select").val() != "" &&
                            $("#supplier_select").val() != 1) //所选择商家不是壹果时 可以手动输入产品编码和SKU编码
                        {

                            $(".creatSize").show();
                        } else {
                            $.alert("商品编码" +
                                $("[name=productCode]").val() +
                                "不存在");
                            return false;
                        }
                    }
                }
            });

        }
        //检验SKU编码
        var checkSKUCode = function () {
            var that = $(this);
            if ($(this).val() != "") {
                $.ajax({
                    type: "get",
                    url: App.getContextPath() +
                        "admin/product/checkSkuCode.do",
                    data: {
                        skuCode: $(this).val(),
                        id: $(this).closest("tr").find("td:eq(0)").html()
                    },
                    async: true,
                    success: function (result) {
                        if (result == true) {
                            $.alert("SKU编码 " + $(that).val() + " 已存在");
                            $(that).val("");
                            return false;
                        } else {
                            return true
                        }
                        ;
                    }
                });
            }
        }
        //商品详情图的编辑
        var upLoadImg = function () {

            $("[upload-file=detailImageUrl]")
                .fileupload({
                    url: App.getContextPath() +
                        "admin/file/uploadFile.do",
                    formData: {
                        fileType: "ProductDetailImage"
                    },
                    dataType: 'json',
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png|JPG?g)$/i,
                    iframe: true,
                    start: function (e) {
                        $('.progress').fadeIn(300);
                        return true;
                    },
                    autoUpload: true,
                    done: function (e, data) {
                        var result = data.result;
                        var $tr = $(this).closest("form");
                        $tr
                            .find("[hidden-image]")
                            .append(
                                "<input type='hidden' name='imagePath' value='" + result.fileUrl + "' />");
                        $tr
                            .find(".image_preview_default")
                            .html(
                                "<img src='" + result.fileUrl + "' />");

                    },
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded /
                            data.total * 100, 10);
                        $('.progress .progress-bar').css(
                            'width', progress + '%');
                    }
                }).on('fileuploaddone', function (e, data) {
                $(".progress").fadeOut(300);

            });
        }

        //获取图片库
        var getImagesList = function () {
            var url = App.getContextPath() + "admin/images/searchImages.do";
            var type = $("#ImagesType_select").val();
            if (type != -1 && type != null)
                url += "?q=" + type;

            if ($mainDataTable) {
                $mainDataTable.api().ajax.url(url).load();
                return;
            }
            var dtSetting = $
                .dataTableSetting({
                    "ajaxSource": url,
                    "serverSide": true,
                    "bFilter": false, // 去掉搜索框
                    "bLengthChange": true, // 每页显示数量
                    "sScrollX": "100%",
                    "sScrollXInner": "100%",
                    "iDisplayLength": 10,

                    "bSort": false,
                    "aoColumns": [{
                        "mDataProp": "imagePath",
                        "sTitle": "图片",
                        "width": "200px",
                        "class": "imagePath",
                        "render": function (data, type, row) {
                            return "<a target='_blank' href='" + row.imagePath + "'><img width='30px' height='30px' src=" +
                                (row.imagePath) + "></a>";
                        }
                    }, {
                        "mDataProp": "tags",
                        "sTitle": "图片类型",
                        "class": "tags",
                        "width": "200px",
                        "render": function (data, type, row) {
                            if (row.tags == "QuantityCheck")
                                return "质检报告";
                            if (row.tags == "Size")
                                return "尺码表";
                            return row.tags;

                        }
                    }, {
                        "sTitle": "操作",
                        "width": "100px",
                        "render": function (data, type, row) {
                            return "<a class='btn btn-danger btn-xs btn-width bt-insert' style='width:60px;margin-bottom:5px;' href='javascript:;'>使用</a>";

                        }

                    }]
                });

            $mainDataTable = $("#db_Images_list").dataTable(dtSetting);

        }

        var loadTmallImage = function () {
            $.blockUI();
            $
                .ajax({
                    type: "get",
                    url: App.getContextPath() +
                        "admin/product/getProductImagesByTmall.do",
                    data: {
                        tid: $("[name=tmallId]").val()
                    },
                    async: true,
                    success: function (result) {
                        $.unblockUI();
                        $("#nestable2").find("li").remove();
                        //设置商品主图
                        $
                            .each(
                                result.productImages,
                                function (index, item) {
                                    var url = item.imagePath
                                        .indexOf("http") < 0 ? "http:" +
                                        item.imagePath :
                                        item.imagePath;
                                    addMainImageHtml(url, "");
                                });
                        $("#detailImage").find("li").remove();

                        //设置商品详情图
                        $.each(result.detailImagePath.split(','),
                            function (index, item) {
                                addDetailHtml(item);
                            });

                    }
                });
        }
        var vipRateChange = function (rate) {
            var productSalePrice = $("input[name=productSalePrice]").val();
            if (!productSalePrice) {
                return;
            }
            $("input[name=vipPrice]").val(
                Math.floor(productSalePrice * (1 - rate)));

        }
        var getWebAttribute = function (id) {
            var str = "";
            $
                .ajax({
                    type: "get",
                    url: App.getContextPath() +
                        "admin/attribute/findAttributeByParentId.do",
                    data: {
                        parentId: id
                    },
                    async: true,
                    success: function (result) {
                        if (result != null) {
                            if (result.extra.length > 0) {
                                tagsList = result.extra;
                                $
                                    .each(
                                        result.extra,
                                        function (index, item) {
                                            str += '<input type="checkbox" value=' + item.attributeName + ' name="tags"><span>' +
                                                item.attributeName +
                                                '</span></input>';
                                        });
                                $(".tagsList").empty().append(str);

                            }
                        }
                    }
                });

        }
        //获取一级类
        var loadParentCategory = function () {
            $("#category2_select").empty().append('<option>请选择二级分类</option>');
            $("#category3_select").empty().append('<option>请选择三级分类</option>');
            $.ajax({
                type: "get",
                url: App.getContextPath() + "admin/product/getParentCategory.do",
                async: false,
                success: function (result) {
                    if (result.length > 0) {
                        var data = eval(result);
                        var option = "<option value=''>选择分类</option>";
                        $.each(data, function (index, item) {
                            option += "<option value='" + item.id + "'>" + item.categoryName + "</option>";
                        });
                        $("#category1_select").empty().append(option);
                        $('#category1_select').off("change").change(function () {
                            loadCategory3ById($('#category1_select').val(), 2);
                        })
                    }
                }
            });

        };
        var loadCategory3ById = function (id, level) {
            $.ajax({
                type: "get",
                url: App.getContextPath() + "admin/product/getCategoryByParentId.do",
                data: {
                    parentId: id
                },
                async: false,
                success: function (result) {
                    if (result.length > 0) {
                        var data = eval(result);
                        var option = "";
                        $.each(data, function (index, item) {
                            option += "<option value='" + item.id + "'>" + item.categoryName + "</option>";
                        });
                        if (level == 2) {
                            $("#category2_select").empty().append(option);
                            $('#category2_select').off("change").change(function () {
                                loadCategory3ById($('#category2_select').val(), 3);
                            })
                            $("#category2_select").trigger("change")
                        }

                        if (level == 3)
                            $("#category3_select").empty().append(option);
                    }
                }

            });
        };
        //根据categoryId 获取父级信息
        var getParentsCategory = function (id) {

            $.ajax({
                type: "get",
                url: App.getContextPath() + "admin/product/getParentsByCategoryId.do",
                data: {
                    categoryId: id
                },
                async: true,
                success: function (result) {
                    if (result != null && result.length > 0) {
                        $("#category1_select").get(0).value = result[0].id;
                        $("#category1_select").trigger("change");

                        setTimeout(function () {
                            $("#category2_select").get(0).value = result[1].id;
                            $("#category2_select").trigger("change");
                            setTimeout(function () {
                                $("#category3_select").get(0).value = result[2].id;
                            }, 300);
                        }, 300);
                    }
                }
            });

        };
        var tagsList = [];
        return {
            init: function () {
                flag = $.getUrlParam("flag");
                id = $.getUrlParam("id") || null;
                groupId = $.getUrlParam("groupId");
                //loadGroup();
                //loadBrand();
                //loadStyle();
                //loadSupplier();
                getWebAttribute(16);
                //根据天猫Id获取商品图片
                $(".bt-loadimage").click(function () {
                    if ($("[name=tmallId]").val().trim().length == 0)
                        return false;
                    if (id != null) {
                        $.confirm("重新加载图片会清楚掉之前所有图片", function () {
                            loadTmallImage();
                        });

                    } else {
                        loadTmallImage();
                    }
                });

                $("#style_select").select2();
                $("#vipRate_select").select2({
                    placeholder: "选择女王折扣"
                });
                $("#promotionType_select").select2({
                    placeholder: "选择商品类型"
                });
                $("#s2id_promotionType_select").addClass("width_100");


                $(".uniform").uniform();
                App.init();
                FormWizard.init();
                $(".bt-addSize").click(addSize);

                fileUpLoad();

                detailFileUpLoad();
                $('#formWizard .submitBtn').click(saveProduct).hide();

                $("[name=productCode]").blur(function () {
                    getSizeList();
                    /* if (id == null) {

                    } else {
                        // getSizeList();
                        checkProductCode();
                    } */

                });

                if (flag == "edit" || flag == "group" || flag == "copy") {
                    getProductInfo(id);
                }

                //回车事件注册在添加尺码上
                document.onkeydown = function (e) {
                    var ev = document.all ? window.event : e;
                    if (ev.keyCode == 13) {
                        $(".bt-addSize").trigger("click");
                    }
                };
                $("input[name=productName]").focus();
                $("[name=productSalePrice]")
                    .blur(
                        function () {
                            $("#skulist").find("tbody tr").find(
                                "[name=salesPrice]").val(
                                $(this).val());

                        });
                $("[name=p_distributionPrice]")
                    .blur(
                        function () {
                            $("#skulist").find("tbody tr").find(
                                "[name=distributionPrice]").val(
                                $(this).val());

                        });
                $("[name=productOriginalPrice]").blur(
                    function () {
                        $("#skulist").find("tbody tr").find(
                            "[name=orgPrice]").val($(this).val());

                    });
                /*  $("[name=newCustomPrice]").blur(function(){
                     $("#skulist").find("tbody tr").find("[name=newCustomPrice]").val($(this).val());

                }); */
                $("[name=vipPrice]").blur(
                    function () {
                        $("#skulist").find("tbody tr").find(
                            "[name=vipPrice]").val($(this).val());

                    });

                $("#ImagesType_select").select2();
                //显示图库
                $(".fromImages").click(
                    function () {
                        $("#box-config").modal("show");
                        setTimeout(function () {
                            getImagesList();
                            $("#db_Images_list").off("click").on(
                                "click",
                                ".bt-insert",
                                function () {
                                    var tr = $(this).closest("tr");
                                    addDetailHtml($(tr).find(
                                        ".imagePath").find(
                                        "img").attr("src"));
                                    $(this).hide();
                                });
                            $(".searchImages").click(getImagesList);
                        }, 200)

                    });
                $("#vipRate_select").select2().change(function () {
                    vipRateChange($(this).val())
                });
                //显示款式
                $(".bt-selectGroup").click(function () {
                    $("#editGroup").modal("show");
                    loadGroup();
                    $("#searchGroup").click(loadGroup);
                    $("#group_select").select2({
                        placeholder: "选择款式"
                    });
                    $("#group_select").attr("tabindex", 1);
                    $("#editGroup").find(".bt-save").off("click").click(function () {
                        $("[name=groupName]").val($("#group_select option:selected").text())
                        $("[name=groupId]").val($("#group_select").val())
                        $("#editGroup").modal("hide");

                    })
                    $("#editGroup").find(".bt-default").off("click").click(function () {
                        $("#editGroup").modal("hide");
                    })
                })
                //显示商家
                $(".bt-selectSupplier").click(function () {
                    $("#editSupplier").modal("show");
                    loadSupplier();
                    $("#searchSupplier").click(loadSupplier);

                    $("#editSupplier").find(".bt-default").off("click").click(function () {
                        $("#editSupplier").modal("hide");
                    })
                })
                //显示品牌
                $(".bt-selectBrand").click(function () {
                    $("#editBrand").modal("show");
                    loadBrand();
                    $("#editBrand").click(loadBrand);
                    $("#editBrand").find(".bt-default").off("click").click(function () {
                        $("#editBrand").modal("hide");
                    })
                })
            }
        }
    }();
    $(function () {
        $("#header").load("../head.html");
        AddProduct.init();
    });
</script>

<!-- /JAVASCRIPTS -->
</body>

</html>